home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 2
/
Gekikoh Dennoh Club Vol. 2 (Japan).7z
/
Gekikoh Dennoh Club Vol. 2 (Japan) (Track 01).bin
/
games
/
mashou
/
plugin
/
topal.c
< prev
next >
Wrap
Text File
|
1997-06-02
|
2KB
|
105 lines
/*
パレット色変更
toPAL.x filename.PAL
filename.PAL パレットファイル 非圧縮.PALのみ対応
return 0:no error
1:no memory error
2:command error
3:file open error etc.
徐々に、パレットが、指定した、PALファイルの色になる。
by SJOM
*/
#include <sys/iocs.h>
#include <stdlib.h>
#include <stdio.h>
static char *pallist; /*[0]blue [1]red [2]green [3]I */
static void
pal_tocol(char *pallist)
{
int block,code,col=0,bl=0,rd=0,gr=0;
for (block=1;block<16;block++) {
_iocs_spalet(0,block,-1); /* dummy */
for (code=0;code<16;code++) {
gr=_iocs_spalet(code+0x80000000,block,-1);
bl=(gr>>=1) & 31;
rd=(gr>>=5) & 31;
gr>>=5;
if (bl!=pallist[0]) {
if (bl>pallist[0]) {
bl--;
} else {
bl++;
};
};
if (rd!=pallist[1]) {
if (rd>pallist[1]) {
rd--;
} else {
rd++;
};
};
if (gr!=pallist[2]) {
if (gr>pallist[2]) {
gr--;
} else {
gr++;
};
};
col=(gr<<11) | (rd<<6) | (bl<<1) | pallist[3];
_iocs_spalet(code+0x80000000,block,col);
pallist+=4;
};
};
}
static void
pal_set(FILE *file,char *list)
{
int i=0,color=0,b=0;
for (i=0;i<240;i++) {
if ((b=fgetc(file))==EOF)
exit(3);
color=b*256; /* b<<8 */
if ((b=fgetc(file))==EOF)
exit(3);
color+=b;
list[3]=color & 1; /* I */
*list++=(color>>=1) & 31; /* blue */
*list++=(color>>=5) & 31; /* red */
*list++=(color>>=5); /* green */
list++;
};
}
int
main(int argc,char **argv)
{
int j=0;
FILE *pat_file=malloc(sizeof(FILE *));
if (pat_file==NULL)
exit(1);
if ((pallist=malloc(240*4))==NULL)
exit(1);
if (argc!=2)
exit(2);
argv++;
if ((pat_file=fopen(*argv,"rb"))==NULL)
exit(3);
pal_set(pat_file,pallist);
for (j=0;j<32;j++) {
pal_tocol(pallist);
};
/* fclose(pat_file); */
exit(0);
}